package com.wxdc.nmgyt.nmgytwydc.dagger.module;

import android.app.Application;

import com.wxdc.nmgyt.nmgytwydc.app.MyApp;
import com.wxdc.nmgyt.nmgytwydc.http.RetrofitHelper;
import com.wxdc.nmgyt.nmgytwydc.http.api.RetrofitService;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * Created by Administrator on 2018/4/20.
 */
@Module
public class AppModule {
    MyApp mApp;
    public AppModule(MyApp app){
        this.mApp = app;
    }
    @Provides   //诉Dagger providesApplicationContext()这个方法是MyApp的实例的提供者
    @Singleton  //告诉Dagger整个生命周期中只会被初始化一次
    MyApp provideApplicationContext(){
        return mApp;
    }

    @Provides
    @Singleton
    RetrofitHelper provideRetrofitHelper(RetrofitService retrofitService){
        return new RetrofitHelper(retrofitService);
    }
}
